#!/usr/bin/perl

# $ARGV[0] is the directory.
# $ARGV[1] is the no intron retention splicing counts directory.
# $ARGV[2] is the with intron retention splicing counts directory.

opendir (BOWTIE_RESULTS, "$ARGV[0]") || die "Can't open bowtie directory:$ARGV[0]";
while ($bowtie_file = readdir(BOWTIE_RESULTS)){
    $splicing_file = $bowtie_file;
    $splicing_file =~ s/bowtie/splicing/;

    print "$bowtie_file\n";

system("perl tally_splices_no_introns.pl ../references/splice_sites-28_norepeats_with_strands.fa $ARGV[0]/$bowtie_file Illumina strand_info.txt > $ARGV[1]/$splicing_file");

system("perl tally_splices_with_introns.pl ../references/splice_sites-28_norepeats_with_strands.fa $ARGV[0]/$bowtie_file Illumina strand_info.txt > $ARGV[2]/$splicing_file");

}

closedir (BOWTIE_RESULTS);
